// 忽略打包的文件
const igonePath = [
  /^\/vite\./,
  /^\/src\/*/,
  /^\/\.e/,
  /^\/\.g/,
  /^\/\.p/,
  /\.d\.ts$/,
  /package-lock\.json$/,
  /tsconfig\.json$/,
  /forge\.config\.ts$/
]

function ignore(path: string) {
  for (const iterator of igonePath) {
    if (iterator.test(path)) {
      return true
    }
  }

  return false
}

module.exports = {
  packagerConfig: {
    // asar: true
    junk: true,
    ignore
  },
  rebuildConfig: {},
  makers: [
    {
      name: '@electron-forge/maker-squirrel',
      config: {}
    },
    {
      name: '@electron-forge/maker-zip',
      platforms: ['darwin']
    },
    {
      name: '@electron-forge/maker-deb',
      config: {}
    },
    {
      name: '@electron-forge/maker-rpm',
      config: {}
    }
  ],
  plugins: [
    {
      name: '@electron-forge/plugin-vite',
      config: {
        // `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
        // If you are familiar with Vite configuration, it will look really familiar.
        build: [
          {
            // `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
            entry: 'src/main.ts',
            config: 'vite.main.config.ts'
          },
          {
            entry: 'src/preloads/preload.ts',
            config: 'vite.preload.config.ts'
          }
        ],
        renderer: [
          {
            name: 'main_window',
            config: 'vite.renderer.config.ts'
          }
        ]
      }
    }
    // {
    //   name: '@electron-forge/plugin-auto-unpack-natives',
    //   config: {}
    // }
  ]
}
